<?php

namespace App\Http\Controllers\Shop;

use App\Http\Controllers\ShopController;
use App\Models\Product\Product as ProductModel;
use App\Models\Product\Type as TypeModel;

class HomeController extends ShopController
{
    public function index()
    {
        $recommendData = ProductModel::where(['flag' => (String)3,'status' => (String)1])->orderBy('createtime','desc')->limit(6)->get();
        
        $TypeData = TypeModel::orderBy('weigh','desc')->limit(8)->get();

        $newData = ProductModel::where(['flag' => (String)1])->orderBy('createtime','desc')->limit(4)->get();

        $hotData = ProductModel::where(['flag' => (String)2])->orderBy('createtime','desc')->limit(6)->get();
        
        $data = [
            'recommendData' => $recommendData,
            'TypeData' => $TypeData,
            'newData' => $newData,
            'hotData' => $hotData
        ];

        return $this->success('查询成功',$data);
    }
}
